---
title: Build Images with Docker
sidebar_label: docker
---

import ConfigPartial from '../../_partials/v2beta1/images/docker.mdx'


If nothing is specified, DevSpace always tries to build the image using Docker as build tool.


## Kaniko Fallback
When using `docker` as build tool, DevSpace checks if the Docker daemon is installed and running. If Docker is not installed or not running, DevSpace will use kaniko as fallback to build the image unless the option `disableFallback` is set to `true`.

#### Example: Disabling kaniko Fallback
```yaml
images:
  backend:
    image: john/appbackend
  frontend:
    image: john/appfrontend
    docker:
      disableFallback: true
```
**Explanation:**  
- The first image `backend` would be built using Docker and if Docker is not available, the image would be built using kaniko as a fallback.
- The second image `frontend` would be built using Docker and if Docker is not available, DevSpace would exit with a fatal error instead of using the kaniko fallback.


## Minikube Docker Daemon
DevSpace preferably uses the Docker daemon running in the virtual machine that belongs to your local Kubernetes cluster instead of your regular Docker daemon. This has the advantage that images do not need to be pushed to a registry because Kubernetes can simply use the images available in the Docker daemon belonging to the kubelet of the local cluster. Using this method is only possible when your current kube-context points to a local Kubernetes cluster and is named `minikube`, `docker-desktop` or `docker-for-desktop`.

#### Example: Building Images in Minikube
```yaml
images:
  backend:
    image: john/appbackend
    docker:
      preferMinikube: true
  frontend:
    image: john/appfrontend
    docker:
      preferMinikube: false
```
**Explanation:**  
- The first image `backend` would be preferably built with Minikube's Docker daemon and the image would **not** be pushed to a registry.
- The second image `frontend` would **not** be built with the Docker daemon of Minikube and it would be pushed to a registry after building and tagging the image using Docker (or kaniko as fallback).


## Custom `args` For `docker build`
The `args` option expects an array of strings to be passed as arguments and flags to the `docker build` command.

#### Example: Docker Args
```yaml
images:
  backend:
    image: john/appbackend
    docker:
      args:
      - "--no-cache"
      - "--compress"
```

:::warning
When specifying `args`, DevSpace will invoke your installed Docker CLI via a command-line call instead of using the built-in Docker client. This has the negative effects that:
- The kaniko fallback will not be used anymore.
- You need to make sure that everyone who is using this configuration has the same version (or a compatible one) of Docker installed.
:::


## Config Reference

<ConfigPartial/>
